//! \file pairsocket.hpp
//! \brief Purewell Library Pair Socket Header
//! \author Yubin Lim (purewell@gmail.com)
//! \since 2008-01-25

#ifndef __PWHDR_PAIRSOCKET_HPP__
#define __PWHDR_PAIRSOCKET_HPP__

#include "pairfile.hpp"
#include "socket.hpp"

namespace purewell
{

//! \brief Pair socket.
class PWPairSocket : public PWPairFile
{
public:
	//! \brief Initialize pair socket.
	//! \param[in] name Socket file name.
	//! \param[in] flags Flags.
	//! \param[in] omode Open modes.
	virtual bool initialize(const char* name, int flags, int omode);

public:
	//! \brief Receive packet from socket.
	//! \param[out] buf Buffer.
	//! \param[in] blen Buffer length.
	//! \param[in] flag Flags.
	//! \param[in] idx File descriptor index.
	//! \return Operated size or -1.
	virtual ssize_t receive(void* buf, size_t blen, int flag, size_t idx);

	//! \brief Send packet from socket.
	//! \param[in] buf Buffer.
	//! \param[in] blen Buffer length.
	//! \param[in] flag Flags.
	//! \param[in] idx File descriptor index.
	//! \return Operated size or -1.
	virtual ssize_t send(const void* buf, size_t blen,
		int flag, size_t idx);

public:
	explicit PWPairSocket();
	virtual ~PWPairSocket();
};

};

#endif//!__PWHDR_PAIRSOCKET_HPP__

